﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;

namespace Lyon.Register
{
    public partial class RegisterForm : Form
    {
        public RegisterForm()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Text = String.Format(this.Text, SimpleRegister.AppName);
            textBox4.Text = SimpleRegister.AppName;
            textBox2.Text = SimpleRegister.MachineID;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(TB_Lincese.Text.Trim()))
            {
                MessageBox.Show("注册码不能为空");
                return;
            }
            if (!SimpleRegister.Authenticate(TB_Lincese.Text.Trim()))
            {
                MessageBox.Show("注册失败！");
                return;
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                TB_Lincese.Text = System.IO.File.ReadAllText(openFileDialog1.FileName);
            }
        }
    }
}
